1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Data;
5 using System.Drawing;
6 using System.Linq;
7 using System.Text;
8 using System.Threading.Tasks;
9 using System.Windows.Forms;
10 using System.Drawing.Imaging;
11
12 using PatternRecognition.FingerprintRecognition.Core;
13 using PatternRecognition.ROC;
14 using PatternRecognition.FingerprintRecognition.FeatureExtractors;
15 using PatternRecognition.FingerprintRecognition.Matchers;
16 using PatternRecognition.FingerprintRecognition.ResourceProviders;
17 using ImageProcessingTools;
18
19
20 namespace Fingerprint_Recognition_Project
21 {
22 public partial class Form1 : Form
23 {
24
25 public Form1()
26 {
27 InitializeComponent();
28 }
29
30 public string score;
31 public string qry;
32 public string temp;
33
34 private Bitmap Change_Resolution(string file)
35 {
36 using (Bitmap bitmap = (Bitmap)Image.FromFile(file))
37 {
38 using (Bitmap newBitmap = new Bitmap(bitmap))
39 {
40 newBitmap.SetResolution(500,500);
41 return newBitmap;
42 }
43 }
44 }
45
46
47
48 private void match(string query, string template)
49 {
50 Change_Resolution(query);
51 Change_Resolution(template);
52 // Loading fingerprints
53 var fingerprintImg1 = ImageLoader.LoadImage(query);
54 var fingerprintImg2 = ImageLoader.LoadImage(template);
55 //// Building feature extractor and extracting features
56 var featExtractor = new PNFeatureExtractor() { MtiaExtractor = new Ratha1995MinutiaeExtractor() };
57 var features1 = featExtractor.ExtractFeatures(fingerprintImg1);
58 var features2 = featExtractor.ExtractFeatures(fingerprintImg2);
59
60 // Building matcher and matching
61 var matcher = new PN();
62 double similarity = matcher.Match(features1, features2);
63 score = similarity.ToString("0.000");
64 MessageBox.Show(similarity.ToString("0.000"));
65
66 }
67
68
69 private void Form1_Load(object sender, EventArgs e)
70 {
71 //// Change_Resolution("C:/Users/Olaseyo/Documents/Visual Studio 2015/Projects/Fingerprint_Recognition_Project/Fingerprint_Recognition_Project/bin/Debug/binaryfiles/101_1.tif","101_1.bmp");
72 //Change_Resolution("C:/Users/Olaseyo/Documents/Visual Studio 2015/Projects/Fingerprint_Recognition_Project/Fingerprint_Recognition_Project/bin/Debug/binaryfiles/101_4.tif", "binaryfiles/101_4.bmp");
73 //// Loading fingerprints
74 //var fingerprintImg1 = ImageLoader.LoadImage("C:/Users/Olaseyo/Documents/Visual Studio 2015/Projects/Fingerprint_Recognition_Project/Fingerprint_Recognition_Project/bin/Debug/binaryfiles/101_1.bmp");
75
76
77 //var fingerprintImg2 = ImageLoader.LoadImage("C:/Users/Olaseyo/Documents/Visual Studio 2015/Projects/Fingerprint_Recognition_Project/Fingerprint_Recognition_Project/bin/Debug/binaryfiles/101_4.bmp");
78
79
80 //pictureBox1.ImageLocation = "C:/Users/Olaseyo/Documents/Visual Studio 2015/Projects/Fingerprint_Recognition_Project/Fingerprint_Recognition_Project/bin/Debug/binaryfiles/101_1.bmp";
81
82 //pictureBox2.ImageLocation = "C:/Users/Olaseyo/Documents/Visual Studio 2015/Projects/Fingerprint_Recognition_Project/Fingerprint_Recognition_Project/bin/Debug/binaryfiles/101_4.bmp";
83
84
85
86 ////// Building feature extractor and extracting features
87 //var featExtractor = new PNFeatureExtractor() { MtiaExtractor = new Ratha1995MinutiaeExtractor() };
88 //var features1 = featExtractor.ExtractFeatures(fingerprintImg1);
89 //var features2 = featExtractor.ExtractFeatures(fingerprintImg2);
90
91 //// Building matcher and matching
92 //var matcher = new PN();
93 //double similarity = matcher.Match(features1, features2);
94 //MessageBox.Show(similarity.ToString("0.000"));
95
96 }
97
98
99
100 //public string Return_Filename(string filename) {
101 // string[] strarray= null;
102 // char[] splitchar = {'\\','.'};
103 // int totarray;
104 // for (int i = 0; i < splitchar.Length; i++)
105 // {
106 // strarray = filename.Split(splitchar[i]);
107 // totarray = strarray.Length;
108
109
110 // }
111 // string realname_ext = strarray[totarray - 1];
112 //}
113
114
115 private void button1_Click(object sender, EventArgs e)
116 {
117 OpenFileDialog dlg = new OpenFileDialog();
118 dlg.ShowDialog();
119
120 if (dlg.ShowDialog() == DialogResult.OK)
121 {
122 string fileName;
123 fileName = dlg.FileName;
124 qry = fileName;
125 pictureBox1.ImageLocation = qry;
126
127 }
128 }
129
130 private void button2_Click(object sender, EventArgs e)
131 {
132 OpenFileDialog dlg = new OpenFileDialog();
133 dlg.ShowDialog();
134
135 if (dlg.ShowDialog() == DialogResult.OK)
136 {
137 string fileName;
138 fileName = dlg.FileName;
139 temp= fileName;
140 pictureBox2.ImageLocation = temp;
141 }
142 }
143
144 private void button3_Click(object sender, EventArgs e)
145 {
146 match(qry, temp);
147 }
148
149 private void panel4_Paint(object sender, PaintEventArgs e)
150 {
151
152 }
153 }
154 }